﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import __AS3__.vec.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class MonthInvestmentConfig extends Object
    {
        private var _investDic:Dictionary;
        private var _rewardArr:Array;
        private static var _instance:MonthInvestmentConfig;

        public function MonthInvestmentConfig()
        {
            this._investDic = new Dictionary();
            this._rewardArr = [];
            if (_instance != null)
            {
                throw new Error(" MonthInvestmentConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_invest.json");
            this.write(_loc_1);
            _loc_1 = ConfigManager.instance.getJSONByFileName("t_invest_base.json");
            this.writeBase(_loc_1);
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TInvest = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TInvest();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                if (this._rewardArr[_loc_2.type] == null)
                {
                    this._rewardArr[_loc_2.type] = new Vector.<TInvest>;
                }
                (this._rewardArr[_loc_2.type] as Vector.<TInvest>).push(_loc_2);
            }
            return;
        }// end function

        private function writeBase(param1:Object) : void
        {
            var _loc_2:TInvestBase = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TInvestBase();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._investDic[_loc_2.type] = _loc_2;
            }
            return;
        }// end function

        public function getInvestBaseByType(param1:int) : TInvestBase
        {
            return this._investDic[param1];
        }// end function

        public function get investDic() : Dictionary
        {
            return this._investDic;
        }// end function

        public function get rewardArr() : Array
        {
            return this._rewardArr;
        }// end function

        public function getInvestListByType(param1:int) : Vector.<TInvest>
        {
            return this._rewardArr[param1];
        }// end function

        public static function get instance() : MonthInvestmentConfig
        {
            if (_instance == null)
            {
                _instance = new MonthInvestmentConfig;
            }
            return _instance;
        }// end function

    }
}
